#ifndef _PFS_CALULATOR_
#define _PFS_CALULATOR_ XD
// ---- ---- 0w0 ---- ----
#include <climits>
#include "pfs_item.h"

class PFS_Calculator {
public:
	typedef std::vector<int> Solution;

	struct Answer {
		Answer(int sc, Solution solu): score(sc), solution(solu) {} 
		int score; Solution solution;
	};

	explicit PFS_Calculator(const PFS_Item& pfs_item, double time_limit);
	virtual ~PFS_Calculator() {}
	virtual Answer Calculate() = 0;

	int Score(const Solution& solution) const;
	Solution GetRandomSolution() const;
	Solution GetNeighbor(Solution solution) const;

	double time_limit() const { return time_limit_; }

	static const int kWorstScore = INT_MAX;

protected:	
	void InitResult();
	void PushAnswer(int score, const Solution& solution);
	Answer best_answer() const { return Answer(best_score_, best_solution_); }

private:
	const PFS_Item pfs_item_;
	const double time_limit_;
	bool IsBestScore(int score) const { return score < best_score_; }

	// * Do NOT modify this member without InitResults() or SetBestScore() *
	int best_score_;
	Solution best_solution_;

	mutable RandomGen<int> random_job;
};


// ---- ---- >w< ---- ----
#endif  // _PFS_CALULATOR_